<template>
	<ChatView />
</template>

<script setup lang="ts">
import ChatView from "./components/ChatView.vue";

import { useChatStore } from "./store/chat";
const chatStore = useChatStore();

if (chrome && chrome.runtime && chrome.runtime.connect) {
	// 与 background script 建立连接
	const port = chrome.runtime.connect({ name: "sidePanelBridge" });

	port.postMessage({ action: "sidePanel", data: "侧边栏已打开" });

	// 监听来自 background script 的消息
	port.onMessage.addListener((msg) => {
		if (msg.action === "content") {
			chatStore.updateContentData(msg.data);
		}
	});
}
</script>

<style scoped></style>
